package com.xuecheng.order.controller;

import com.xuecheng.commons.model.vo.OrdersVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.order.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 订单前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class OrdersController {

    @Autowired
    private OrdersService  ordersService;
    // 用户下单
    @PostMapping("/orders/create/{coursePubId}")
    public ResponseResult<String> createOrder(@PathVariable ("coursePubId")Long coursePubId) {
        return ordersService.createOrder(coursePubId);
    }
    // 查询支付结果
    @GetMapping("/orders/{orderNo}")
    public ResponseResult<OrdersVo> isPay(@PathVariable("orderNo") String orderNo) {
        return ordersService.isPay(orderNo);
    }
}